<?php
/**
 * Copyright (c) 2009, Jacek Karczmarczyk
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * - Neither the name of the author nor the names of its contributors may be
 *   used to endorse or promote products derived from this software without
 *   specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * PHP Version 5
 *
 * @package Larchana_EntryPoint
 * @version 0.1
 * @author Jacek Karczmarczyk <jacek@karczmarczyk.pl>
 */
 
error_reporting(E_ALL);
ob_start("ob_gzhandler");
header("Content-Type: text/html; charset=UTF-8");

function getmicrotime()
{ 
	list($usec, $sec) = explode(" ",microtime()); 
	return ((float)$usec + (float)$sec); 
}
if (get_magic_quotes_gpc()) {
	function stripslashes_array(&$arr) {
		foreach($arr as $key=>&$value)
			if (is_array($value))
				stripslashes_array($value);
			else
				$value = stripslashes($value);
	}
	stripslashes_array($_GET);
	stripslashes_array($_POST);
	stripslashes_array($_REQUEST);
	stripslashes_array($_COOKIE);
	@set_magic_quotes_runtime(0);
}

$microtime = getmicrotime();

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH',
              realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', isset($_GET['debug']) && $_GET['debug'] ? 'development' : 'production');

define('LIB_ROOT', dirname(dirname(dirname(dirname(__FILE__)))).DIRECTORY_SEPARATOR.'lib');
ini_set('include_path', 
	implode(PATH_SEPARATOR, array(
		'.',
		APPLICATION_PATH,
		realpath(LIB_ROOT.DIRECTORY_SEPARATOR.'ZendFramework-1.9.2'),
		realpath(LIB_ROOT.DIRECTORY_SEPARATOR.'Larchana'),
	))
);

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();

print "<!--\nPage rendered in ".number_format(getmicrotime()-$microtime, 3)."s, memory peak usage: ".number_format(memory_get_peak_usage()/1024/1024, 3)."MB\n-->";

die();

?>
